/*https://leetcode.cn/problems/maximum-ice-cream-bars/submissions/564722978/*/
class Solution {
public:
    int maxIceCream(vector<int>& costs, int coins) {
        int n = costs.size();
        sort(costs.begin(),costs.end());//对雪糕定价进行排序
        int cnt = 0;
        if(costs[0] > coins)return 0;
        for(int i = 0;i < n;i++){
            if(coins >= costs[i]){//当前剩余的硬币足够购买该雪糕
            coins -= costs[i];
            cnt++;
            }else break;
        }
        return cnt;
    }
};